// =======================================================================
// 
//       Filename:  textelement.hpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  20.04.2010 00:40:31
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dominik 'domachine' Burgdörfer (-), dominik.burgdoerfer@googlemail.com
//        Company:  -
// 
// =======================================================================


#ifndef  TEXTELEMENT_INC
#define  TEXTELEMENT_INC
#include "element.hpp"
#include <boost/filesystem.hpp>

namespace webplodder {
    // Forward declaration
    namespace utils {
        class CIterator;
    }

    namespace elements {
        class File;

        class Text : public Element
        {
            public:
                Text(Element& parent, Type type = TEXT);

                Text(Element& parent, 
                        int begin, int end,
                        Type type = TEXT);

                ~Text();

                int begin() const;

                void setBegin(int begin);

                int end() const;

                void setEnd(int end);

                void setInput(utils::CIterator& input);

                void setExternalFile(const boost::filesystem::path& 
                                                            filePath);

                boost::filesystem::path externalFile() const;

                bool hasExternalFile() const;

                virtual bool operator>>(char& ch);

                friend Text& operator>>(char ch, Text& element);

            protected:
                virtual bool getChar(char& ch);

            private:
                int mBegin;
                int mEnd;
                utils::CIterator* mIterator;
                boost::filesystem::path m_externalFilePath;
                std::string mBuffer;
                bool mCache;
                unsigned int mIndex;
        };
    }
}
#endif   // ----- #ifndef TEXTELEMENT_INC  -----
